package main

import (
	"errors"
	"iot-base/common/modbus"
	"iot-base/devc/common/loader"
	"strconv"
)

func ControlDelay(cmd loader.ServiceCmd, param map[string]interface{}, client modbus.Client) (map[string]interface{}, error) {
	ret := make(map[string]interface{})
	if cmd.InputParams == nil {
		return nil, er("input param is nil!")
	}
	id, ok := param["ID"].(string)
	if !ok {
		return nil, er("parse id is err")
	}
	iid, _ := strconv.ParseUint(id, 10, 32)
	cword, ok := param["word"].(string)
	if !ok {
		return nil, er("parse word is err")
	}
	iword, _ := strconv.ParseUint(cword, 10, 32)
	res, err := GetResultEx("6", uint16(iid)*14+42, uint16(iword), nil, client, "serve")
	if err != nil {
		return nil, er("get res err:" + err.Error())
	}
	ret["msg"] = string(res)
	return ret, nil
}

func er(erstr string) error {
	return errors.New(erstr)
}

func ParseInput() {

}
